﻿using System;
using System.Data;
using System.Data.SqlClient;

public  class UnsubscribeMeDAL
    {
      dbConnection db = new dbConnection();
      public  int UnSubscribeMe(string UserName)
      {
          SqlConnection cn = null;
          SqlCommand cmd = null;
          int Counter = 0;

          try
          {
              cn = new SqlConnection();
              cn.ConnectionString = db.GetCS();
              cmd = new SqlCommand();
              cmd.Connection = cn;
              cmd.CommandType = CommandType.Text;
              cmd.CommandText = "Delete  from Registrations where UserName=@UserName";
           cmd.Parameters.AddWithValue("@UserName", UserName);


              cn.Open();
              Counter = cmd.ExecuteNonQuery();
          }
          catch (Exception ex)
          {
              throw new Exception(ex.Message);
          }
          finally
          {
              if (cn != null)
              {
                  cn.Close();
                  cn.Dispose();
                  cn = null;
              }
          }
          return (Counter);
      }

    }

